关于autoit:要使用AutoIt3 HotKeySet来模拟AutoHotKey应用程序筛选

您所在的位置:网站首页 autohotkey autoit 关于autoit:要使用AutoIt3 HotKeySet来模拟AutoHotKey应用程序筛选

关于autoit:要使用AutoIt3 HotKeySet来模拟AutoHotKey应用程序筛选

#关于autoit:要使用AutoIt3 HotKeySet来模拟AutoHotKey应用程序筛选 | 来源: 网络整理| 查看: 265

目标

我正在构建一个通用解决方案,用于使用AutoIt3对任意程序UI进行高级控制,方法是通过按各种键或发出命令来调用。

组件

TargetUI-通过发送点击和按键来控制的程序 MainAu3-AutoIt程序进行发送 MainIni-以专用符号包含控制位置和其他信息的文件,还包含热键信息。所有信息都特定于特定的TargetUI-即。每个TargetUI都有一个MainIni KeyHookScript-可选? AutoIt或AutoHotKey脚本

事实

HotKeySet()-AutoIt函数允许设置和取消系统范围的热键 AutoHotKey-脚本语言-允许应用程序通过#IfWinActive筛选热键 MainAu3当前被设计为采用一些KeyHookScript提供的命令参数 MainAu3的调用速度很慢,这是由于在启动时解析了MainIni,这非常重要。由于计划目标

问题

由于MainAu3的调用速度较慢,因此一种选择是使其在后台运行并具有自己的键钩,或者让KeyHookScript以某种方式与其通信 MainAu3和MainIni将具有多个实例-每个TargetUI都有一个实例。如果在每个MainAu3中使用HotKeySet(),这将导致冲突,除非您每次TargetUI都获得焦点时都进行了设置和取消设置-这似乎是在自找麻烦

预期方法

看来我将需要一个MainAu3Manager来监视应用程序,并确保根据需要运行正确的MainAu3 / MainIni。它还需要维护以AutoHotKey编写的Singleton(?)KeyHookScript

问题

尝试通过每个MainAu3基于具有焦点且是TargetUI的应用程序换出HotKeySet / Unset有多么不明智? 鉴于这是一种不好的方法,哪种通信方法最好与正在运行的MainAu3进行通信? 通过_IsPressed在AutoIt中创建我自己的挂钩机制有多么困难,并且如果它在每个MainAu3中频繁运行,会产生一个"轮询问题"吗?

通讯方式

这些都是我能想到的,我希望它快速可靠,并且易于编码哈哈

基于文件的-在包含命令的某个目录中创建文件,让MainAu3删除该文件/ 注册表-可能比文件慢 隐藏的窗口-通过设置窗口文本(我知道!)比文件更快地进行通信? 隐藏的窗口-SendMessage哎呀,太难编码了 DDE-不要让我开始

决策点

无论出于何种原因,我都需要与正在运行的MainAu3进行通信。真正的问题是是否将Keyhook机制嵌入MainAu3实例中。

我想要的是,如果AutoIt具有可靠的机制来处理特定于应用程序的按键挂钩,例如AutoHotKeys #IfWinActive。

如果我嵌入,我既讨厌设置和取消设置HotKeySet()的选项,又讨厌轮询_IsPressed()。再说一次,通过AutoHotKey进行的外部按键钩也很麻烦。

我想我会先尝试嵌入HotKeySet(),然后看看它是如何工作的。

有什么建议吗?

注意 "通信"是一种方式-我只需要发送命令。

相关讨论 一次问一个问题呢? _IsPressed不可靠。

如果您要控制的GUI是您自己的GUI:

如果要使用非系统范围的热键,则应使用

GUISetAccelerators ( accelerators [, winhandle] )

123GUISetAccelerators Sets the accelerator table to be used in a GUI window.

参数

12accelerators    A 2 dimensional array holding the accelerator table (See remarks). winhandle   [optional] Windows handle as returned by GUICreate() (default is the previously used window).

备注

1234567891011The array passed to this function contains the hotkey and the control ID of the accelerator. The array must be defined as Local/Global $aArray[n][2] - where n is the number of accelerator keys to set:     $aArray[0][0] = Hotkey (in HotKeySet() format) of 1st accelerator     $aArray[0][1] = Control ID of the 1st accelerator, as returned by GUICtrlCreate...     $aArray[1][0] = Hotkey of 2nd accelerator     $aArray[1][1] = Control ID of the 2nd accelerator     ...     $aArray[n][0] = Hotkey of nth accelerator     $aArray[n][1] = Control ID of the nth accelerator Passing this function a non-array will unset all accelerators for the given winhandle.

示例:

123456789101112131415161718192021222324252627282930313233343536373839#include #include Example() Func Example()     GUICreate("Custom MsgBox", 225, 80)     GUICtrlCreateLabel("Please select a button.", 10, 10)     Local $idYes = GUICtrlCreateButton("Yes", 10, 50, 65, 25)     Local $idNo = GUICtrlCreateButton("No", 80, 50, 65, 25)     Local $idExit = GUICtrlCreateButton("Exit", 150, 50, 65, 25)     ; Set GUIAccelerators for the button controlIDs, these being Ctrl + y and Ctrl + n     Local $aAccelKeys[2][2] = [["^y", $idYes],["^n", $idNo]]     GUISetAccelerators($aAccelKeys)     GUISetState(@SW_SHOW) ; Display the GUI.     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 MsgBox($MB_SYSTEMMODAL,"You selected","Close")                 ExitLoop             Case $idYes                 MsgBox($MB_SYSTEMMODAL,"You selected","Yes") ; Displays if the button was selected or the hotkey combination Ctrl + y was pressed.             Case $idNo                 MsgBox($MB_SYSTEMMODAL,"You selected","No") ; Displays if the button was selected or the hotkey combination Ctrl + n was pressed.             Case $idExit                 MsgBox($MB_SYSTEMMODAL,"You selected","Exit")                 ExitLoop         EndSwitch     WEnd     GUIDelete() ; Delete the GUI. EndFunc   ;==>Example

如果您要控制外部GUI,则可以尝试摆弄Any GUI以使其正常工作



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3